<template>
	<view class="p-30">
		<common-list @load="getLandlordAssetsList" :list="list" :status="status">
			<template #list>
				<view class="item bg1" v-for="(item, i) in list" :key="i" @click="click(item)">
					<text
						class="font-24 opy-6 line-1">{{item.province_name}}{{item.city_name}}{{item.district_name}}</text>
					<text class="m-t-20 line-1">{{item.address}}</text>
				</view>
			</template>
			<template #empty>
				<empty text="列表空空如也～"></empty>
			</template>
		</common-list>
		<Watermark color='#FFF1F1' :watermark="mark" :maxWidth="200" />
	</view>
</template>

<script>
	export default {
		name: "assets",
		data() {
			return {
				list: [],
				status: 'loading',
				page: 1,
			}
		},
		onLoad() {
			this.getLandlordAssetsList()
		},
		onReachBottom() {
			if (this.status === 'nomore') return
			this.getLandlordAssetsList()
		},
		methods: {
			click(item) {
				this.$store.commit('SET_SELECT_ASSETS', item)
				this.goBack()
			},
			async getLandlordAssetsList() {
				const {
					page,
					limit
				} = this
				let params = {
					page,
					limit,
				}
				this.status = 'loading'
				const res = await this.$api.common.landlord('getLandlordAssetsList', params)
				if (res.code === 200) {
					const {
						count,
						list
					} = res.data
					this.list = [...this.list, ...list]
					if (this.list.length >= count) {
						// 所有数据加载完毕
						this.status = 'nomore'
						return
					}
					// 单次请求数据完毕
					this.status = 'loadmore'
					this.page = this.page + 1
				}
			},
		},

	}
</script>

<style lang="scss" scoped>
	.item {
		display: flex;
		flex-direction: column;
		justify-content: center;
		height: 176rpx;
		color: $c;
		padding: 0 184rpx 0 20rpx;
		border-radius: 16rpx;
		margin-bottom: 30rpx;
	}

	.bg {
		background: url(@/static/images/user/bg_zichan_moni_hui_2@2x.png) 0 0 no-repeat;
		background-size: 100% 100%;
	}

	.bg1 {
		background: url(@/static/images/user/bg_zichan_moni_2@2x.png) 0 0 no-repeat;
		background-size: 100% 100%;
	}
</style>
